<template>
  <div class="question-wrap">
    <SingleCheck
      :questionData="data"
      :mode="mode"
      :seq="seq"
      v-if="data.question_type == 0"
      @submitAnswer="handleSubmitItem"
    >
    </SingleCheck>
    <MultiCheck
      :questionData="data"
      :mode="mode"
      :seq="seq"
      v-if="data.question_type == 2"
      @submitAnswer="handleSubmitItem"
    >
    </MultiCheck>
    <Discuss
      :questionData="data"
      :mode="mode"
      :seq="seq"
      v-if="data.question_type == 1"
      @submitAnswer="handleSubmitItem"
    >
    </Discuss>

    <div class="detail" v-if="mode === 'score'">
      <div>
        参考答案:<span style="padding-left: 5px">{{
          data.refer_to_answer
        }}</span>
      </div>
    </div>
    <div v-if="mode === 'score' || mode === 'answer'" class="score-wrap">
      <span class="title">得分</span>
      <el-input
        style="width: 180px"
        :disabled="data.question_type == 0 || mode === 'answer'"
        v-model="data.cur_score"
      ></el-input>
    </div>
  </div>
</template>

<script>
import SingleCheck from "./singleCheck.vue";
import MultiCheck from "./multiCheck.vue";
import Discuss from "./discuss.vue";

import { ExamQuestionCache } from "@/api/qms.js";

export default {
  name: "questionIndex",
  components: { SingleCheck, MultiCheck, Discuss },
  props: ["data", "seq", "recordId", "answerList", "mode"],
  data() {
    return {};
  },
  mounted() {},
  methods: {
    handleSubmitItem(params) {
      ExamQuestionCache({
        record_id: this.recordId * 1, //
        ...params,
      });
      const _answerList = [...this.answerList];
      _answerList[this.seq - 1].fill_content = params.fill_content;
      this.$emit("update:answerList", _answerList);
      // console.log(this.seq, params.fill_content, this.answerList);
    },
  },
};
</script>
<style lang="scss" scoped>
::v-deep .el-checkbox,
.el-checkbox__input {
  display: inline-block;
  position: relative;
  white-space: normal !important;
}

::v-deep .el-radio {
  white-space: normal !important;
}

.question-wrap {
  margin-bottom: 10px;

  /deep/.question-name {
    line-height: 36px;

    white-space:wrap .q-text {
      margin-left: 3px;

      .q-text-score {
        color: orange;
      }
    }

    .img-wrap {
      width: 100%;
      float: left;
      box-sizing: border-box;
      padding: 5px 0px;

      img {
        width: 100%;
      }
    }
  }

  /deep/.question-content {
    padding: 5px 15px;
    width: 100%;
    box-sizing: border-box;

    .el-checkbox-group {
      width: 100%;

      .el-checkbox {
        width: 50%;
        box-sizing: border-box;
        margin-right: 0;
        padding: 5px 30px 0 0;
        white-space: wrap !important;

        .el-checkbox__label {
          display: inline;
          padding-left: 5px;
        }

        .img-wrap {
          width: 100%;
          float: left;
          box-sizing: border-box;
          padding: 5px 0px;

          // margin-left: -22px;
          img {
            width: 100%;
          }
        }
      }
    }

    .el-radio-group {
      width: 100%;

      .el-radio {
        width: 50%;
        box-sizing: border-box;
        margin-right: 0;
        padding: 5px 10px 0 0;

        // white-space: wrap;
        .el-radio__label {
          padding-left: 5px;
        }

        .img-wrap {
          width: 100%;
          float: left;
          box-sizing: border-box;
          padding: 5px 0px;

          img {
            width: 100%;
          }
        }
      }
    }
  }

  .detail {
    background: #f8f8f8;
    padding: 20px 15px;

    font-size: 14px;
    color: #222222;

    // img {
    //   max-width: 600px;
    //   margin-left: 100px;
    //   margin-top: 20px;
    // }
  }

  .score-wrap {
    display: flex;
    justify-content: flex-end;
    padding: 10px 0;

    .title {
      line-height: 28px;
      padding-right: 10px;
    }
  }
}
</style>